package com.cloud.cloudshop.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
@EnableOpenApi
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .groupName("webApi")
                .pathMapping("/")
                .select()
                .paths(PathSelectors.regex("/.*"))
                .apis(RequestHandlerSelectors.basePackage("com.cloud.cloudshop.shop.controller")) // 设置扫描路径
                .build();
    }

    private ApiInfo apiInfo() {

        return new ApiInfoBuilder().title("我的接口文档").version("1.0.0").contact(new Contact("xiaoli","www.baidu.com","544852009@qq.com"))
                .description("描述信息").license("license test").build();

    }
}